package com.grademaster.controller;

import com.grademaster.common.R;
import com.grademaster.dto.StudentDto;
import com.grademaster.dto.StudentPageDto;
import com.grademaster.service.StudentInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/student")
@Api(tags = "学生相关接口")
@CrossOrigin(origins = {"http://localhost:8081"}, allowCredentials = "true")
public class StudentInfoController {

    @Autowired
    private StudentInfoService studentInfoService;


    @ApiOperation("获取所有学生分页信息")
    @GetMapping("/getAllStudentsByPage")
    public R getAllStudentsByPage(StudentPageDto studentPageDto) {
        return studentInfoService.getAllStudentsByPage(studentPageDto);
    }
    @ApiOperation("导出成绩列表到Excel")
    @GetMapping("/exportExcel")
    public ResponseEntity exportExcel(StudentPageDto studentPageDto){
        return studentInfoService.exportExcel(studentPageDto);
    }

    @ApiOperation("修改学生班级")
    @PostMapping("/editStudentClass")
    public R editStudentClass(@RequestBody StudentDto studentDto) {
        return studentInfoService.editStudentClass(studentDto);
    }


}
